package com.xm_jd.controller.dd;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xm_jd.model.dao.index2Dao;
import com.xm_jd.model.entitys.IndexVO;
import com.xm_jd.utils.BaseServlet;

/**
 * Servlet implementation class index2
 */
@WebServlet("/index2")
public class index2 extends BaseServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public index2() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		
		List<IndexVO> sp = new index2Dao().getOrderId(1);
		
		
		Map<Integer, List<IndexVO>> map = new HashMap<>();
		for (IndexVO i : sp) {
			List<IndexVO> tmp = new index2Dao().getselectsp(i.getDd_id());
			map.put(i.getDd_id(), tmp);
		}
		
//		//获取订单的id
//		String dd = request.getParameter("id");
//		//修改订单状态
//		new index2Dao().updatezt(dd);
		
		if(sp.size()>0){
			request.setAttribute("sp", sp);
			request.setAttribute("map", map);
		}
		request.setAttribute("index", 1);
		//request.getRequestDispatcher("jsps/dd/dd_index2.jsp").forward(request, response);;
		this.forward("dd/dd_index2");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
